@extends('admin::layouts.master')
@section('title')
    添加礼包
@endsection
@section('tab')
		<div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form" >
                	{{csrf_field()}}
                    {{hi_form_hidden('id',3)}}

                    <div class="layui-form-item x-city">
                        <label class="layui-form-label"><span class="x-red">*</span>张数</label>
                        <div class="layui-input-inline">
                            <input type="number" id="username" name="p_num" required="" value="{{$info['p_num']}}" lay-verify="required" placeholder="请输入banner展示张数" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item x-city">
                        <label class="layui-form-label"><span class="x-red">*</span>间隔（秒）</label>
                        <div class="layui-input-inline">
                            <select name="num" lay-filter="province">
                                <option value="">请选择时间间隔</option>
                                @for( $i = 1 ; $i<=5 ; $i++ )
                                    <option value="{{$i}}" @if($info['num'] == $i) selected="" @endif >{{$i}}</option>
                                @endfor
                            </select>
                        </div>
                    </div>

                    <div class="layui-form-item">
                       <label for="L_repass" class="layui-form-label"></label>
                       <!-- 邀请数据的设置  设置好以后 不可以修改 否则会导致数据错乱 -->
                        <button class="layui-btn" lay-filter="but_save" lay-submit="">确认</button>
                    </div>
                    
        		</form>
        	</div>
        </div>

@endsection

@section('tab_js')
    <script>
        layui.use(['form', 'layer', 'jquery'], function () {
            $ = layui.jquery;
            var form = layui.form,
            layer = layui.layer;
            //监听提交
            form.on('submit(but_save)', function (data) {
            	layer.confirm("确认要修改吗", function(index){
	                $.ajax({
	                    url: js_url('admin-banner-set_update'),
	                    type: 'post',
	                    data: data.field,
	                    dataType: "json",
	                    success: function (result) {
	                        if (result.state === 0) {
	                            layer.msg("更新成功", {time: 500, icon: 6}, function () {
	                                //关闭当前frame
	                                xadmin.close();
	                                // 可以对父窗口进行刷新
	                                xadmin.father_reload();
	                            });
	                        } else {
	                            layer.msg(result.msg, {time: 500, icon: 5});
	                        }
	                    }
	                });
	            })
                return false;
            });
            
        });
    </script>
@endsection